//
//  BoxSizeTableViewCell.m
//  ForestPack
//
//  Created by 郑洲 on 2018/7/18.
//  Copyright © 2018年 郑洲. All rights reserved.
//

#import "BoxSizeTableViewCell.h"

@implementation BoxSizeTableViewCell

+ (BoxSizeTableViewCell *)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellID = @"BoxSizeTableViewCell";
    BoxSizeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[BoxSizeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.backgroundColor = [UIColor whiteColor];
        [cell createSubView];
    }
    
    return cell;
}

- (void)createSubView {
    UILabel *noteLabel = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(13), ScreenX375(22), ScreenX375(80), ScreenX375(16))];
    noteLabel.text = @"内径尺寸：";
    noteLabel.textColor = REXADECIMALCOLOR(@"#333333");
    noteLabel.font = Kfont(14);
    [self addSubview:noteLabel];
    
    NSArray *noteArr = @[@"长",@"宽",@"高"];
    for (int i = 0; i < 3; i++) {
        UILabel *classNote = [[UILabel alloc] initWithFrame:CGRectMake(ScreenX375(80) + i % 2 * ScreenX375(151), ScreenX375(22) + i / 2 * ScreenX375(40), ScreenX375(16), ScreenX375(16))];
        classNote.text = noteArr[i];
        classNote.textColor = REXADECIMALCOLOR(@"#333333");
        classNote.font = Kfont(14);
        [self addSubview:classNote];
        
        UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 12, ScreenX375(30))];
        UILabel *rightView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, ScreenX375(30), ScreenX375(30))];
        rightView.text = @"cm";
        rightView.textColor = REXADECIMALCOLOR(@"#999999");
        rightView.font = Kfont(13);
        
        UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(ScreenX375(98) + i % 2 * ScreenX375(151), ScreenX375(15) + i / 2 * ScreenX375(40), ScreenX375(106), ScreenX375(30))];
        textField.layer.cornerRadius = ScreenX375(15);
        textField.layer.borderWidth = 0.8;
        textField.layer.borderColor = REXADECIMALCOLOR(@"#dcdcdc").CGColor;
        textField.clipsToBounds = YES;
        textField.leftView = leftView;
        textField.rightView = rightView;
        textField.leftViewMode = UITextFieldViewModeAlways;
        textField.rightViewMode = UITextFieldViewModeAlways;
        textField.keyboardType = UIKeyboardTypeNumberPad;
        if (i == 0) {
            _longField = textField;
            if (kNSUDefaultReadKey(@"BoxSizeLong")) {
                _longField.text = kNSUDefaultReadKey(@"BoxSizeLong");
            }
        }else if (i == 1) {
            _widthField = textField;
            if (kNSUDefaultReadKey(@"BoxSizeWidth")) {
                _widthField.text = kNSUDefaultReadKey(@"BoxSizeWidth");
            }
        }else {
            _heightField = textField;
            if (kNSUDefaultReadKey(@"BoxSizeHeight")) {
                _heightField.text = kNSUDefaultReadKey(@"BoxSizeHeight");
            }
        }
        [self addSubview:textField];
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
